package cn.tedu.store.config;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class UDPserver {

    public static void main(String[] args) throws Exception {
        System.out.println("udp服务启动");
        //创建连接
        DatagramSocket datagramSocket = new DatagramSocket(8080);

        //接受数据
        byte[] bytes = new byte[1024];
        DatagramPacket datagramPacket = new DatagramPacket(bytes,bytes.length);

        datagramSocket.receive(datagramPacket);
        //接收数据


        System.out.println(new String(datagramPacket.getData(),0,datagramPacket.getLength()));
    }
}
